<template>
	<div class="yue-box">
		 <div class="yue-top">
		 	<span>可用余额</span>
		 	<p v-text="'￥'+num" id="quanbu">￥999.99</p>
		 	<router-link to="/tixianmingxi">提现明细</router-link>
		 </div>
		 <div class="yue-shuruk">
		 	<span>本次提现</span>
		 	<span>￥</span>
		 	<input type="number" placeholder="请输入本次提现金额" v-model="refundjine" @input="jinegeshi()"/>
		 </div>
		 <div class="yue-list">
		 	<h4>提现方式</h4>
		 	<ul>
		 		<li @click="zhifustatus=1">
		 			<span><img src="../../img-user/chongzhi.png"/></span>
		 			<span>提现到银行卡</span>
		 			<span>
		 				<img src="../../img-address/icon_dis@3x.png" v-show="zhifustatus!=1"/>
		 				<img src="../../img-address/icon_select @3x.png" v-show="zhifustatus==1"/>
		 			</span>
		 		</li>
		 		<li @click="zhifustatus=2">
		 			<span><img src="../../img-user/zhifubao.png"/></span>
		 			<span>提现到支付宝</span>
		 			<span>
		 				<img src="../../img-address/icon_dis@3x.png" v-show="zhifustatus!=2"/>
		 				<img src="../../img-address/icon_select @3x.png" v-show="zhifustatus==2"/>
		 			</span>
		 		</li>
		 	</ul>
		 </div>
		 <p class="yue-btn" @click="queurytixian"><span>确认提现</span></p>
	</div>
</template>

<script>
	
	export default{
		data () {
			return{
				user:0,
				zhifustatus:1,
				tixianxinxi:{},
				txmoney:'',
				refundjine:'',
				num:''
			}
		},
		created:function(){
			this.user=localStorage.getItem("nt_user");
		},
		
		methods:{
			queurytixian:function(){
				var self=this;
				if(this.refundjine>0&&this.refundjine!=""){
					localStorage.setItem("nt_refundjine",self.refundjine);
					if(this.zhifustatus==1){
						this.$router.push({path:"/bankcard"});
					}
					if(this.zhifustatus==2){
						this.$router.push({path:"/zhifubao"});
					}
				}
				
			},
			jinegeshi:function(){
				if(this.refundjine<0){
					this.refundjine=0;
				}else{
					var self=this;
					var obj=self.refundjine;
					obj = obj.replace(/[^\d.]/g,""); //先把非数字的都替换掉，除了数字和. 
					obj = obj.replace(/^\./g,""); //必须保证第一个为数字而不是. 
					obj = obj.replace(/\.{2,}/g,"."); //保证只有出现一个.而没有多个. 
					obj = obj.replace(".","$#$").replace(/\./g,"").replace("$#$","."); //保证.只出现一次，而不能出现两次以上 
					if(obj.replace(/^[0]/g,"")!=self.refundjine&&obj.replace(/^[0]/g,"")>=1){
						self.refundjine=obj.replace(/^[0]/g,"");
					}else{
						if(obj==""){
							self.refundjine='0';	
						}else{	
							if((obj.toString()).indexOf('.')!=-1){
								//有小数点的话
								if(obj.split("").length-(obj.toString()).indexOf('.')>3){
									self.refundjine=Number(obj.substring(0,(obj.toString()).indexOf('.')+3));
								}
							}	
						}
						if(Number(obj)>Number(self.num)){
							self.refundjine='';
						}
					}
				}
			},
		},
		qbtx: function(){
			
		},
		mounted:function(){
			var self=this;
			$.ajax({
				type:"get",
				url:furl+"index.php?app=ajax_epay&act=withdraw",
				data:{'token':self.user},
				dataType:'json',
				success:function(res){
					
					if(res.done){
						self.tixianxinxi=res.retval.epay;
						self.num=res.retval.epay.money;
						console.log("ok")
					}
				}
			});
		}
	}
</script>

<style>
	.yue-box{font-size: 0;}
	.yue-top{background-color:#fff;border-bottom: 1px solid #e8e8e8;text-align: center;padding-top: 0.4rem;padding-bottom: 0.35rem;}
	.yue-top>span{font-size:0.32rem;color:#2B2B2B;line-height: 0.72rem;}
	.yue-top>p{font-size:0.72rem;color:#2B2B2B;line-height: 1.04rem;font-weight: bold;}
	.yue-top>a{font-size:0.32rem;color:#fb9722;line-height: 0.82rem;}
	
	.yue-shuruk{background-color:#fff;line-height: 1.2rem;height:1.2rem;box-sizing: border-box;padding-left: 0.32rem;padding-right: 0.32rem;}
	.yue-shuruk>span:first-child{color:#2E2E2E;font-size:0.28rem;margin-right: 0.46rem;}
	.yue-shuruk>input{height:1.2rem;color:#2B2B2B;font-size:0.28rem;width:3rem;}
	.yue-shuruk>span:nth-child(2){color:#2B2B2B;font-size:0.4rem;margin-right: 0.1rem;}
	.yue-list{margin-top: 0.16rem;background-color:#fff;padding-left: 0.32rem;padding-right: 0.32rem;}
	.yue-list>h4{height:0.88rem;line-height: 0.88rem;font-size:0.28rem;color:#CCCCCC;border-bottom: 1px solid #E8E8E8;font-weight:500;}
	.yue-list li{height:1rem;line-height: 1rem;}
	.yue-list li>span:first-child{display: inline-block;float:left;margin-right: 0.4rem;}
	.yue-list li>span:nth-child(2){font-size:0.28rem;color:#2E2E2E;}
	.yue-list li>span:first-child>img{width:0.5rem;height:0.5rem;}
	.yue-list li>span:last-child{float:right;}
	.yue-list li>span:last-child>img{width:0.32rem;height:0.32rem;}
	.yue-btn{margin: 0.6rem 0.32rem;height:1rem;text-align: center;line-height: 1rem;color:#fff;letter-spacing: 0.2rem;box-sizing: border-box;font-size:0.32rem;
	background: -webkit-linear-gradient(left, #fb9722 , #ffb661); 
    background: -o-linear-gradient(right, #fb9722, #ffb661); 
    background: -moz-linear-gradient(right, #fb9722, #ffb661);
    background: linear-gradient(to right, #fb9722 , #ffb661);
	border-radius:0.5rem;padding-left: 0.6rem;}
</style>